package com.demo.encapsulation;

public class MyString {

	
	public static void main(String[] args) {
		
		
		String s="Hello";
		String s1=new String("Hello");
		
		System.out.println(s==s1);  // chekcing on reference. 
		System.out.println(s);
		System.out.println(s1); //string class has overriden toString mehtod thats why we are getting 
		System.out.println(s.equals(s1));
		
		s1=s1.intern();
		System.out.println(s==s1);

		//String objects are immutable 
		//what is immutable ? 
		//if anyone change in that object a new object will be created rather than modifing same object. 
		
	  //s=	 s.concat(" World");
		 s=s+" World";
		 System.out.println("S= "+s);
		 System.out.println("S1= "+s1);
		 String myWorld="A" + " B"; //3 objects are being created. 
		 System.out.println(myWorld);
		 
		 String myWorld2="           A "+" B" +" c"+" D         "; //total object 7
		 
		 System.out.println("Myworld2 : "+ myWorld2.trim());
		myWorld2=myWorld2.toLowerCase().trim();
		
		 System.out.println(myWorld2);
		
		 System.out.println(myWorld.charAt(2));

		 System.out.println(myWorld2.indexOf("b c"));
		 
		 String name="Anshul Singh";
		 
		 System.out.println(name.indexOf("Singh1"));
		 
		 //Array  <Employee type > find all 
		 //create a program that takes array of employee records  and hold it into memory
		 //1:- find all records whose last name is Singh 
		 //2:- find all records whose salary is greater than 20000
		 
		  if(name.indexOf("Singh1")!=-1){
			  System.out.println("Singh availble.");
		  }else {
			  System.out.println("not availble..");
		  }
		 
		 
		 //i18n --internationalization
		  //l10n - localiz
		 
		
	}
	
}
